package com.bage.finance.biz.job;

import com.bage.finance.biz.service.VoucherService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
public class VoucherJobService {

    final VoucherService voucherService;

    /**
     * 刷新凭证数据到es中
     * @param param
     * @return
     */
    @XxlJob("resetVoucherDocumentJob")
    public ReturnT<String> resetVoucherDocumentJob(String param) {
        XxlJobHelper.log("resetVoucherDocumentJob -> begin");
        try {
            XxlJobHelper.log("凭证开始同步到es中...");
            voucherService.resetVoucherDocument();
            XxlJobHelper.log("凭证同步到es结束...");
        } catch (Exception e) {
            XxlJobHelper.log("任何执行失败", e);
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
